package com.lungle.warmdiary.app.view.me.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lungle.warmdiary.R;
import com.lungle.warmdiary.app.model.response.ActiveState;
import com.lungle.warmdiary.app.view.me.view.BaseViewHolder;

import java.util.List;


public class ActiveStateAdapter extends BaseAdapter {
    private Context mContext;

    public List<ActiveState.Item> nums;
//    public int[] colors = {0xFFFBBA5A, 0xFF897172, 0xFF31B909, 0xFF6895BD, 0XFFFA4848, 0XFFFA4851, 0XFFC86B46, 0XFFD1B4AD};

    public ActiveStateAdapter(Context mContext, List<ActiveState.Item> nums) {
        super();
        this.mContext = mContext;
        this.nums = nums;
    }

    @Override
    public int getCount() {
        return 8;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.grid_item, parent, false);
        }
//        convertView.setBackgroundColor(Color.GREEN);
        TextView num = BaseViewHolder.get(convertView, R.id.tv_item_num);
        TextView type = BaseViewHolder.get(convertView, R.id.tv_item_type);

        ActiveState.Item item = nums.get(position);

        type.setText(item.getName());
        num.setText(item.getNum() + "");
        type.setTextColor(item.getColor());
        num.setTextColor(item.getColor());

        return convertView;
    }

}
